Repository navigation
feat: record the event types a store holds and hold what newer code wrote (SCHEMA_AHEAD) - #234
Closed
benatespina wants to merge 13 commits into
Closed
benatespina wants to merge 13 commits into
benatespina wants to merge 13 commits into
Conversation
EventStore gains types(): every (aggregateType, type, schemaVersion) of a committed event, recorded by append in its own transaction in a new bounda_event_types table on SQLite, PostgreSQL and the Durable Object, and in the memory store. A set shared by a storage's stores, filled by types(), keeps a booted app from writing rows it already has; a transaction's types count only once it commits. Boot and rebuildReadModel refuse a store holding events the code cannot read (an event type, aggregate or process it no longer has, or a schema version past the one it knows) with one ConfigurationError naming each. What newer code wrote while a deploy rolls out is now the transient SchemaAheadError (SCHEMA_AHEAD): load, readOne and readByPerson throw it, readAll hands out the events before it and throws only when it comes first, a subscriber backs off before it, a reaction holds it without ever giving up, a scheduled command is deferred without an attempt, and a dead-letter retry rejects with it.
benatespina
force-pushed
the
feat/event-catalogue
branch
from
November 7, 2026 09:38
0a581ee to
9a6157e
Compare
# Conflicts: # docs/src/content/docs/adapters/index.mdx
# Conflicts: # packages/core/src/kernel/app.ts # packages/core/src/kernel/read-model/rebuild.ts
# Conflicts: # docs/src/content/docs/adapters/index.mdx # packages/core/src/adapter/sql/index.ts # packages/core/src/adapter/sqlite/adapter.ts # packages/postgresql/src/index.ts
…omer events it holds
# Conflicts: # packages/core/src/kernel/personal-data/export.test.ts
…atalogue # Conflicts: # packages/core/src/adapter/sqlite/adapter.ts # packages/core/src/adapter/sqlite/event-store.ts # packages/core/src/adapter/sqlite/sqlite.test.ts # packages/core/src/adapter/testing/event-store.contract.ts # packages/core/src/kernel/read-model/rebuild.test.ts # packages/core/src/memory/event-store.ts # packages/postgresql/src/event-store.ts # packages/postgresql/src/postgresql.test.ts
…atalogue # Conflicts: # docs/src/content/docs/adapters/index.mdx
…atalogue # Conflicts: # docs/src/content/docs/adapters/index.mdx # docs/src/content/docs/reference/errors.md # packages/core/src/kernel/app.ts # packages/core/src/kernel/personal-data/export.test.ts # packages/core/src/kernel/read-model/rebuild.ts
…atalogue # Conflicts: # packages/core/src/adapter/index.ts # packages/core/src/adapter/sqlite/event-store.ts # packages/core/src/adapter/staged-event-store.ts # packages/core/src/adapter/storage/event-store.ts # packages/core/src/adapter/testing/event-store.contract.ts # packages/core/src/kernel/aggregate/upcasting.test.ts # packages/core/src/kernel/aggregate/upcasting.ts # packages/core/src/kernel/personal-data/event-store.ts # packages/core/src/kernel/personal-data/ledger-append.ts # packages/core/src/memory/event-store.ts # packages/postgresql/src/event-store.ts
…atalogue # Conflicts: # packages/core/src/kernel/personal-data/export.test.ts
Member
Author
|
Superseded by #383, rebuilt on the current main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First of two stacked changes for schema evolution;
feat/event-lineage(formerlyandretired) builds on this one.What changes
EventStore.types()lists every(aggregateType, type, schemaVersion)of a committed event.appendrecords the ones it has not met in its own transaction, in a newbounda_event_typestable (SQLite incore, PostgreSQL, the Durable Object throughcreateSqliteAdapter) and in the memory store. A set shared by a storage's stores, filled bytypes(), keeps a booted app from writing rows it already has; what a transaction records counts only once it commits. Shared SQL pieces live incore/adapter/sql/event-types.ts.checkStoredTypes(kernel/aggregate/stored-types.ts) runs inassembleApp, right after the storage opens and the aggregates are built, and inrebuildReadModel. A store holding an event type, aggregate or process the code no longer has, or a schema version past the one it knows, refuses with oneConfigurationErrornaming each.SchemaAheadError(SCHEMA_AHEAD), transient, for what newer code wrote while a deploy rolls out: a future schema version, or an unknown type the catalogue records (without a row it stays aConfigurationError).load,readOneandreadByPersonthrow it;readAllreturns the events before the first unreadable one and throws only when it comes first.faileddelivery at the event's position: back-off,getLag().failing, nothing dead-lettered.tryClaimalready counts the attempt, so it is counted as today.runtime.dispatcher.backoff.baseDelaywithout an attempt.failed.failure()(React Router) andcreateWorker(Cloudflare) answerSCHEMA_AHEADwith a 503.Docs
reference/errors(SCHEMA_AHEAD,INVALID_CONFIGURATIONat boot, HTTP table),guides/deployment("Deploying a change to events"),adapters(thebounda_event_typesrow),guides/changing-eventsandguides/react-router. Oneminorchangeset for core, postgresql, cloudflare and react-router.Checks
pnpm checkgreen with Docker running (PostgreSQL suite included): 2467 tests.coreandpostgresql; the new code's survivors were killed with new tests except one equivalent mutant (event-types.ts, the initial array of a pending set). The rest are older.eventStoreContractandstorageTransactionContract, which also run inside workerd.